import unittest
from FileDetect import FileDetect


class test_FileDetect(unittest.TestCase):
	def setUp(self):
		self._file_detect = FileDetect()

	def test_if_file_is_not_found_match_is_always_none(self):
		states = self._arrange_states()
		matches = self._file_detect.match('test/data/no_file', states)

		self.assertIsNone(matches)

	def test_a_match_can_be_made(self):
		states = self._arrange_states()
		matches = self._file_detect.match('test/data/file_detect', states)

		self.assertEqual(matches, 'open')

	def _arrange_states(self):
		return [{
			'name': 'open',
			'begin': '1',
			'end': '999',
		}, {
			'name': 'closed',
			'begin': '1',
			'end': '3',
		}, {
			'name': 'not_found',
			'begin': 'q',
			'end': 'w',
		}]
